#include "Codec.h"

Codec::Codec()
{

}
Codec::~Codec()
{

}


Request::Request()
{
}
Request::Request(string encstr)
{
	initMessage(encstr);
}
Request::Request(struct RequestInfo* info)
{
	initMessage(info);
}
void Request::initMessage(string encstr)
{
	m_encStr = encstr;
}
void Request::initMessage(struct RequestInfo* info)
{
	m_msg.set_cmdtype(info->cmd);
	m_msg.set_clientid(info->clientId);
	m_msg.set_serverid(info->serverId);
	m_msg.set_sign(info->sign);
	m_msg.set_data(info->data);
}
string Request::encodeMsg()
{
	string output;
	m_msg.SerializeToString(&output);
	return output;
}
void* Request::decodeMsg()
{
	m_msg.ParseFromString(m_encStr);
	return &m_msg;
}
Request::~Request()
{

}


Response::Response()
{

}
Response::Response(string encstr)
{
	initMessage(encstr);
}
Response::Response(struct ResponseInfo* info)
{
	initMessage(info);
}
void Response::initMessage(string encstr)
{
	m_encStr = encstr;
}
void Response::initMessage(struct ResponseInfo* info)
{
	m_msg.set_rv(info);
}
string Response::encodeMsg()
{
	string output;
	m_msg.SerializeToString(&output);
	return output;
}
void* Response::decodeMsg()
{
	m_msg.ParseFromString(m_encStr);
	return &m_msg;
}
Response::~Response()
{

}